package com.aplink.generic.network;

import java.io.File;

public class GenericFile {
    private boolean isCanDelete = true;
    private String mExtension;
    private String mLocalPath;
    private String mName;
    private String mPhysicalPath;

    public boolean delete() {
        if (this.mLocalPath != null) {
            final File file = new File(this.mLocalPath);
            if (file.exists()) {
                return file.delete();
            }
        }
        return false;
    }

    public String getExtension() {
        return this.mExtension;
    }

    public String getLocalPath() {
        return this.mLocalPath;
    }

    public String getName() {
        return this.mName;
    }

    public String getPhysicalPath() {
        return this.mPhysicalPath;
    }

    public File getRealFile() {
        return new File(this.mLocalPath);
    }

    public boolean isCanDelete() {
        return this.isCanDelete;
    }

    public void setCanDelete(final boolean isCanDelete) {
        this.isCanDelete = isCanDelete;
    }

    public void setExtension(final String extension) {
        this.mExtension = extension;
    }

    public void setFileNameByURl(final String url) {
        final File file = new File(url);
        if (file.exists()) {
            this.mName = file.getName();
        }
    }

    public void setLocalPath(final String localPath) {
        this.mLocalPath = localPath;
    }

    public void setName(final String name) {
        this.mName = name;
    }

    public void setPhysicalPath(final String physicalPath) {
        this.mPhysicalPath = physicalPath;
    }
}
